def write_ep_surface(
        name, 
        type,
        construction, 
        zone, 
        boundary,
        boundary_object, 
        sun_exp, 
        wind_exp, 
        points):

    surface ="! Building Surface\n" +\
    "BuildingSurface:Detailed,\n"+\
    "  "+name+",\n" +\
    "  "+type+",\n" +\
    "  "+construction+",\n" +\
    "  "+zone+",\n" +\
    "  "+boundary+",\n" +\
    "  "+boundary_object+",\n" +\
    "  "+sun_exp+",\n" +\
    "  "+wind_exp+",\n" +\
    "  autocalculate,\n"+\
    "  "+str(len(points))+",\n"
    for counter in range(len(points)):
        point = points[counter]
        text_point = str(point[0])+","+str(point[1])+","+str(point[2])
        if counter < len(points)-1:
            surface = surface + "  "+text_point+",\n"
        else:
            surface = surface + "  "+text_point+";\n\n"
    return surface

def write_ep_window(
        name, 
        construction, 
        surface,
        shading,
        frame,
        points):

    window ="! Window\n"+\
    "FenestrationSurface:Detailed,\n"+\
    "  "+name+",\n"+\
    "  Window,\n"+\
    "  "+construction+",\n"+\
    "  "+surface+",\n"+\
    "  ,\n"+\
    "  autocalculate,\n"+\
    "  "+shading+",\n"+\
    "  "+frame+",\n"+\
    "  1.0,\n"+\
    "  "+str(len(points))+",\n"
    for counter in range(len(points)):
        point = points[counter]
        text_point = str(point[0])+","+str(point[1])+","+str(point[2])
        if counter < len(points)-1:
            window = window + "  "+text_point+",\n"
        else:
            window = window + "  "+text_point+";\n\n" 
    return window

def write_ep_building_shade(
        name, 
        transmittance, 
        points):
    building_shade ="! Building Shade\n"+\
    "Shading:Building:Detailed,\n"+\
    "  "+name+",\n"+\
    "  "+transmittance+",\n"+\
    "  "+str(len(points))+",\n"
    for counter in range(len(points)):
        point = points[counter]
        text_point = str(point[0])+","+str(point[1])+","+str(point[2])
        if counter < len(points)-1:
            building_shade = building_shade + "  "+text_point+",\n" 
        else:
            building_shade = building_shade + "  "+text_point+";\n\n" 
    return building_shade


def write_ep_shadingoverhang(name, window_name, height_above_window,tilt_angle, left_extension, right_extension, depth):
    
    overhang = "! ===========     ALL OBJECTS IN CLASS: SHADING OVERHANG        ===========\n\n"+\
    "Shading:Overhang,\n"+\
    "    " + name + ",\n"+\
    "    " + window_name + ",\n"+\
    "    " + height_above_window + ",\n"+\
    "    " + tilt_angle+ ",\n"+\
    "    " + left_extension+ ",\n"+\
    "    " + right_extension + ",\n"+\
    "    " + depth + ";\n\n"
    return overhang

def write_ep_zone(name):
    zone = "! Building Zone\n"+\
    "Zone,\n"+\
    "  "+name+",\n"+\
    "  0,\n"+\
    "  0, 0, 0, \n"+\
    "  1,\n"+\
    "  1,\n"+\
    "  autocalculate,\n"+\
    "  autocalculate;\n\n"
    return zone 

def write_ep_zone_shade(
        name, 
        base_surface, 
        transmittance, 
        points):

    zone_shade ="! Shading Zone Detailed\n"+\
    "Shading:Zone:Detailed,\n"+\
    "  "+name+",\n"+\
    "  "+base_surface+",\n"+\
    "  "+transmittance+",\n"+\
    "  "+str(len(points))+",\n"
    for counter in range(len(points)):
        point = points[counter]
        text_point = str(point[0])+","+str(point[1])+","+str(point[2])
        if counter < len(points)-1:
            zone_shade = zone_shade + "  "+text_point+",\n" 
        else:
            zone_shade = zone_shade + "  "+text_point+";\n\n" 
    return zone_shade

def write_ep_hvac(template_name, zone_name, thermostat):
    if template_name == "idealloadairsystem":
        hvac = "! Zone Purchased Air\n"+\
        "HVACTemplate:Zone:IdealLoadsAirSystem,\n"+\
        "    "+zone_name+",\n"+\
        "    "+thermostat + ";\n\n"
        
    return hvac

def write_ep_light(light_name, zone_name, schedule):
    if light_name == "generallighting":
        light = "! Zone Lights\n"+\
        "Lights,\n"+\
        "    "+zone_name+"_lights,\n"+\
        "    "+zone_name+",\n"+\
        "    "+ schedule + ",\n"+\
        "    Watts/Area,\n"+\
        "    ,\n"+\
        "    15,\n"+\
        "    ,\n"+\
        "    0,\n"+\
        "    0.42,\n"+\
        "    0.18,\n"+\
        "    1,\n"+\
        "    GeneralLights;\n\n"
        
    return light

def write_ep_building(terrain):
    building = "! =================BUILDING========================\n\n" +\
    "Building,\n" +\
    "    B1,\n"+\
    "     0,\n" +\
    "    " + terrain + ",\n"+\
    "    3.9999999E-02,\n"+\
    "    0.4000000,\n"+\
    "    FullExterior,\n"+\
    "    25;\n\n"
    
    return building

def write_ep_runperiod(start_month, start_day, end_month, end_day):
    runperiod = "RunPeriod,\n"+\
    "    ,\n"+\
    "    " + start_month + ",\n"+\
    "    " + start_day + ",\n"+\
    "    " + end_month + ",\n"+\
    "    " + end_day + ",\n"+\
    "    UseWeatherFile,\n"+\
    "    Yes,\n"+\
    "    Yes,\n"+\
    "    No,\n"+\
    "    Yes,\n"+\
    "    Yes;\n\n"
    
    return runperiod
 
def write_ep_hvacschedule(name, start, end, temp):
    if start != "0:00" and end == "24:00":
         hvac = "Schedule:Compact,\n" +\
         "    " + name + ",\n"+\
         "    Temperature,\n"+\
         "    Through: 12/31,\n"+\
         "    For: AllDays,\n"+\
         "    Until:" + start + ", " + "50.0,\n"+\
         "    Until:" + end + ", " + temp + ";\n\n"
         
    elif start == "0:00" and end == "24:00":
        hvac = "Schedule:Compact,\n" +\
         "    " + name + ",\n"+\
         "    Temperature,\n"+\
         "    Through: 12/31,\n"+\
         "    For: AllDays,\n"+\
         "    Until:" + end + ", " + temp + ";\n\n"
    else:
        hvac = "Schedule:Compact,\n" +\
         "    " + name + ",\n"+\
         "    Temperature,\n"+\
         "    Through: 12/31,\n"+\
         "    For: AllDays,\n"+\
         "    Until:" + start + ", " + "50.0,\n"+\
         "    Until:" + end + ", " + temp + ",\n"+\
         "    Until: 24:00, 50.0;\n\n"
     
    return hvac
 
def write_ep_lightschedule(name, start, end):
    if end == "24:00":
        light = "Schedule:Compact,\n" +\
        "    " + name + ",\n"+\
        "    Fraction,\n"+\
        "    Through: 12/31,\n"+\
        "    For: AllDays,\n"+\
        "    Until:" + start + ", 0,\n"+\
        "    Until:" + end + ", 1;\n\n"
    else:
        light = "Schedule:Compact,\n" +\
        "    " + name + ",\n"+\
        "    Fraction,\n"+\
        "    Through: 12/31,\n"+\
        "    For: AllDays,\n"+\
        "    Until:" + start + ", 0,\n"+\
        "    Until:" + end + ", 1,\n"+\
        "    Until: 24:00, 0;\n\n"
    return light
 
def write_ep_thermostat(name, heat_schedule, cool_schedule):
     thermostat = "HVACTemplate:Thermostat,\n" +\
     "    " + name + ",\n"+\
     "    " + heat_schedule + ",\n"+\
     "    ,\n"+\
     "    " + cool_schedule + ",\n"+\
     "    ;\n\n"
     
     return thermostat

def write_ep_outputvar(variable_name, report_frequency):
    output_var = "Output:Variable,*," + variable_name + " ," + report_frequency + ";\n"
    
    return output_var

def write_ep_outputmeter(variable_name, report_frequency):
    output_meter = "Output:Meter," + variable_name + " ," + report_frequency + ";\n"
    
    return output_meter
